// import { combineReducers } from 'redux'
/* import { combineReducers } from 'redux-immutable'; // combineReducers 合并多个reducer 会转换成 immutable对象

import { reducer as recommendReducer } from '../pages/discover/c-pages/recommend/store';
import { reducer as playerReducer } from '../pages/player/store';

const cReducer = combineReducers({
  recommend: recommendReducer,
  player: playerReducer
});

export default cReducer */

// 传统用法
/* import * as actionTypes from './constants'
import config from '@/config'
import app from './module/app'
import user from './module/user'
const defaultDtate = {
  app,
  user,
  topBanners: [],
  config
}

function reducer (state = defaultDtate, action) {
  switch (action.type) {
    case actionTypes.CHANGE:
      return { ...state, topBanners: [] } // 这种会浪费性能占据内存所以使用immutable
    default:
      return state
  }
} */

// 使用 immutable转换的用法
import { Map } from 'immutable' // map 是浅层比较转换 fromJS深层转换
import * as actionTypes from './constants'
import config from '@/config'
import app from './module/app'
import user from './module/user'
const defaultDtate = Map({
  app,
  user,
  topBanners: [],
  config
})

function reducer(state = defaultDtate, action) {
  switch (action.type) {
    case actionTypes.CHANGE:
      return state.set('topBanners', action.topBanners)
    default:
      return state
  }
}

export default reducer
